#include <iostream>

class Rectangle {
private:
    double a;
    double b;
    
public:
    Rectangle() : a(0), b(0) {} // 无参构造函数
    
    Rectangle(double sideA, double sideB) : a(sideA), b(sideB) {} // 有参构造函数
    
    Rectangle(const Rectangle& other) : a(other.a), b(other.b) {} // 拷贝构造函数
    
    double getSideA() const {
        return a;
    }
    
    double getSideB() const {
        return b;
    }
    
    void setSideA(double side) {
        a = side;
    }
    
    void setSideB(double side) {
        b = side;
    }
    
    bool isSquare() const {
        return a == b;
    }
    
    double getPerimeter() const {
        return 2 * (a + b);
    }
    
    double getArea() const {
        return a * b;
    }
};

void func(Rectangle v, Rectangle* p, Rectangle& r) {
    v.setSideA(10);
    v.setSideB(20);
    std::cout << "Modified v: Side A = " << v.getSideA() << ", Side B = " << v.getSideB() << std::endl;

    p->setSideA(10);
    p->setSideB(20);
    std::cout << "Modified p: Side A = " << p->getSideA() << ", Side B = " << p->getSideB() << std::endl;

    r.setSideA(10);
    r.setSideB(20);
    std::cout << "Modified r: Side A = " << r.getSideA() << ", Side B = " << r.getSideB() << std::endl;
}

int main() {
    Rectangle rectangle1; // 使用无参构造函数创建对象
    Rectangle rectangle2(5, 5); // 使用有参构造函数创建对象
    Rectangle rectangle3 = rectangle2; // 使用拷贝构造函数创建对象

    std::cout << "Rectangle 1: Side A = " << rectangle1.getSideA() << ", Side B = " << rectangle1.getSideB() << std::endl;
    std::cout << "Rectangle 2: Side A = " << rectangle2.getSideA() << ", Side B = " << rectangle2.getSideB() << std::endl;
    std::cout << "Rectangle 3: Side A = " << rectangle3.getSideA() << ", Side B = " << rectangle3.getSideB() << std::endl;

    std::cout << "Is rectangle 2 a square? " << (rectangle2.isSquare() ? "Yes" : "No") << std::endl;
    std::cout << "Perimeter of rectangle 2: " << rectangle2.getPerimeter() << std::endl;
    std::cout << "Area of rectangle 2: " << rectangle2.getArea() << std::endl;

    func(rectangle1, &rectangle2, rectangle3); // 调用函数func

    std::cout << "After func call:" << std::endl;
    std::cout << "Rectangle 1: Side A = " << rectangle1.getSideA() << ", Side B = " << rectangle1.getSideB() << std::endl;
    std::cout << "Rectangle 2: Side A = " << rectangle2.getSideA() << ", Side B = " << rectangle2.getSideB() << std::endl;
    std::cout << "Rectangle 3: Side A = " << rectangle3.getSideA() << ", Side B = " << rectangle3.getSideB() << std::endl;

    return 0;
}